<template>
	<view class="item-box" @longpress="longpress" @click="addCard(info)">
		<view class="pitch-box" v-if="isPitch && isLongpress" @click="pitchClick(0)">
			<u-icon name="checkmark" color='#fff' class="icon-box" @click="pitchClick(0)"></u-icon>
		</view>
		<view class="un-pitch-box" v-if="!isPitch && isLongpress" @click="pitchClick(1)"></view>
		<image class="img-box" mode="scaleToFill" :style="info.is_youxiao == 0 ? 'opacity:0.6' :''" :src="info.goods.image">
			<!-- <u-icon name="shopping-cart" color='#fff' class="icon-box"></u-icon> -->
			<view class="lose-efficacy" v-if="info.is_youxiao == 0">
			</view>
		</image>
		<view class="name-box">
			{{info.goods.title}}
		</view>
		<view class="tags-box">
			<view class="tag-item-box" v-for="(item,index) in info.service_tag" :key='index'>
				{{item.name}}
			</view>
		</view>
		<view class="price-content-box">
			<view class="price-box">
				¥{{info.goods.price}}
			</view>
			<view class="shopping-cart-box" :style="info.is_youxiao == 0 ? 'filter: grayscale(100%);' :''" >
				<u-icon name="shopping-cart" color='#fff' class="icon-box"></u-icon>
			</view>
		</view>
		<view class="cards-box">
			{{info.zeng_text}}
		</view>
	</view>
</template>

<script>
	export default {
		name: "discountsItem",
		props: {
			info: {
				type: Object,
				default: () => {
					return {};
				}
			},
			isPitch: {
				type: Boolean,
				default: () => {
					return false;
				}
			},
			isLongpress: {
				type: Boolean,
				default: () => {
					return false;
				}
			},
		},
		data() {
			return {
			};
		},
		methods: {
			pitchClick(type) {
				this.$emit('pitchClick', type, this.info.id)
			},
			longpress(){
				this.$emit('longpress')
			},
			addCard(info){
				if(info.is_youxiao != 0){
					this.$Router.push({ path: '/pages/goods/new_detail', query: { id: info.goods_id } })
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item-box {
		// padding: 20rpx;
		padding-bottom: 20rpx;
		width: 100%;
		border: 1rpx solid #D3D3D3;
		border-radius: 10rpx;
		position: relative;

		.pitch-box {
			position: absolute;
			left: 30rpx;
			top: 30rpx;
			width: 32rpx;
			height: 32rpx;
			background: #FC5351;
			opacity: 1;
			border: 1px solid #FC5351;
			border-radius: 32rpx;
			z-index: 10;
			display: flex;
			align-items: center;
			justify-content: center;

			.icon-box {
				font-size: 30rpx;
				width: 30rpx;
				height: 30rpx;
			}
		}

		.un-pitch-box {
			position: absolute;
			left: 30rpx;
			top: 30rpx;
			width: 32rpx;
			height: 32rpx;
			background: #FFFFFF;
			opacity: 1;
			border: 1px solid #999999;
			border-radius: 32rpx;
			z-index: 10;
		}

		.img-box {
			width: 100%;
			height: 260rpx;
			border-radius: 16rpx;
			position: relative;
		}
.lose-efficacy{
	position: absolute;
	left: 120rpx;
	top:90rpx;
	width: 120rpx;
	height: 120rpx;
	background-image: url(../../static/images/lose-efficacy.png);
	background-size: 100% 100%;
}
		.name-box {
			margin-left: 20rpx;
			margin-top: 12rpx;
			width: calc(100% - 20rpx);
			height: 40rpx;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 40rpx;
			overflow: hidden;
			    white-space: nowrap;
			    text-overflow: ellipsis;
			// text-align: center;
		}

		.tags-box {
			margin-top: 16rpx;
			margin-left: 20rpx;
			width: calc(100% - 40rpx);
			height: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.tag-item-box {
				width: 90rpx;
				height: 30rpx;
				line-height: 30rpx;
				background-color: #FFF0E4;
				text-align: center;
				font-size: 22rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FE7F1A;
			}
		}

		.price-content-box {
			margin-left: 20rpx;
			width: calc(100% - 20rpx);
			height: 68rpx;
			padding-right: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.price-box {
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #FE7F1A;
				line-height: 68rpx;
			}

			.shopping-cart-box {
				width: 50rpx;
				height: 50rpx;
				margin-top: 12rpx;
				background-color: #FC5351;
				color: #fff;
				border-radius: 50rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				.icon-box {
					width: 30rpx;
					height: 30rpx;
				}
			}
		}

		.cards-box {
			margin-left: 20rpx;
			width: calc(100% - 20rpx);
			height: 30rpx;
			line-height: 30rpx;
			font-size: 20rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #777777;
		}
	}
</style>
